package io.renren.modules.generator.controller;

import java.util.Arrays;
import java.util.Map;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.generator.entity.TbUserMovieCollectionEntity;
import io.renren.modules.generator.service.TbUserMovieCollectionService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author Xiaotianyu
 * @email 805007911@qq.com
 * @date 2021-10-13 15:25:03
 */
@RestController
@RequestMapping("generator/tbusermoviecollection")
@Api("管理员端-用户电影偏好相关增删改查接口")
public class TbUserMovieCollectionController {
    @Autowired
    private TbUserMovieCollectionService tbUserMovieCollectionService;

    /**
     * 列表
     */
    @GetMapping("/list")
    @RequiresPermissions("generator:tbusermoviecollection:list")
    @ApiOperation("分页查询")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tbUserMovieCollectionService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @RequiresPermissions("generator:tbusermoviecollection:info")
    @ApiOperation("根据ID查询")
    public R info(@PathVariable("id") Integer id){
		TbUserMovieCollectionEntity tbUserMovieCollection = tbUserMovieCollectionService.getById(id);

        return R.ok().put("tbUserMovieCollection", tbUserMovieCollection);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @RequiresPermissions("generator:tbusermoviecollection:save")
    @ApiOperation("保存")
    public R save(@RequestBody TbUserMovieCollectionEntity tbUserMovieCollection){
		tbUserMovieCollectionService.save(tbUserMovieCollection);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    @RequiresPermissions("generator:tbusermoviecollection:update")
    @ApiOperation("更新")
    public R update(@RequestBody TbUserMovieCollectionEntity tbUserMovieCollection){
		tbUserMovieCollectionService.updateById(tbUserMovieCollection);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    @RequiresPermissions("generator:tbusermoviecollection:delete")
    @ApiOperation("删除")
    public R delete(@RequestBody Integer[] ids){
		tbUserMovieCollectionService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
